import socket, sys
import time
# 广播地址，设置广播的端口为7788
dest = ('<broadcast>', 7788)

# 创建udp socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# 需要发送广播数据的套接字进行设置，否则不发送广播数据
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)

# 以广播的形式发送数据到本网络的所有电脑
while True:
    s.sendto(b'Hello', dest)
    time.sleep(10)

s.close()




# recvData, recvAddr = s.recvfrom(2048)
# print(recvAddr)